//
//  BorderTextFieldView.m
//  SmartPram
//
//  Created by Kendama on 2017/10/26.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "BorderTextFieldView.h"

@implementation BorderTextFieldView

- (UIView *)bgView
{
    if(!_bgView)
    {
        UIView *superView = self;
        _bgView = [[UIView alloc]init];
        [superView addSubview:_bgView];
        _bgView.layer.cornerRadius = 5;
        _bgView.layer.borderWidth = 1;
        _bgView.layer.borderColor = [UIColor colorWithWhite:0.8 alpha:1].CGColor;
        _bgView.layer.masksToBounds = YES;
    }
    return _bgView;
}
- (UITextField *)textField
{
    if(!_textField)
    {
        UIView *superView = self;
        _textField = [[UITextField alloc]init];
        [superView addSubview:_textField];
        _textField.placeholder = @"请输入您的昵称";
        _textField.font = [UIFont systemFontOfSize:14];
    }
    return _textField;
}

- (void)masLayoutSubview
{
    __weak UIView *superView = self;
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(superView);
    }];
    
    [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.left.mas_equalTo(superView.mas_left).with.offset(pxScaleWidth(20));
        make.right.mas_equalTo(superView.mas_right).with.offset(-pxScaleWidth(50));
    }];
    
}

@end
